﻿using MediatR;
using Sowrk03_28.Repository;
using Swork03_28.Api.Application.Commands.FarmedCommand;
using Swork03_28.Domain.TraceableInfos;

namespace Swork03_28.Api.Application.CommandHandlers.FarmedHandler
{
    public class FirmSelectCommandHandler : IRequestHandler<FirmSelectCommand, FirmInfo>
    {
        private readonly IRepository<FirmInfo> _repository;

        public FirmSelectCommandHandler(IRepository<FirmInfo> repository)
        {
            _repository = repository;
        }

        public async Task<FirmInfo> Handle(FirmSelectCommand request, CancellationToken cancellationToken)
        {
            var info = await _repository.GetValues(x => x.BatchId == request.BatchId);
            return info.FirstOrDefault();
        }
    }
}
